<template>
  <div id="app">	
    <router-view name="first" :key="$route.fullPath"></router-view>
  </div>
</template>

<script>

export default {
  name: 'App',
  created:function(){
  		if(this.cookie.hasKey("useraccount")){
			var useraccount=this.cookie.getValueByKey("useraccount");
			var userpassword=this.cookie.getValueByKey("userpassword");
			this.axios.post("/api/login",{
						useraccount:useraccount,
						userpassword:userpassword
					}).then(function  (data) {
						if (data.data.errs) {
							var ordername = data.data.results[0].ordername;
							this.$store.commit('pushpersonInfor',{login:data.data.results[0]});
							//再次发去数据请求
							this.axios.post("/api/selectuser",{
								ordername:ordername
							}).then(function  (data) {
								if (data.data.errs) {
									this.$store.commit('pushpersonInfor',{selectuser:data.data.results});
									this.userhead=this.$store.state.personInfor[0].login												
									
									//请求购物车数据
									var aaa=this.$store.state.personInfor[0].login.shoppingCarName;
									this.axios.post("/api/getmyCar",{shoppingCarName:aaa}).then(function(data){									
										this.$store.commit('changeCarData',data.data);
									}.bind(this))
								}
							}.bind(this));	
							
						} 
					}.bind(this));
		}
  		
  		
  		
  		
  }
}

</script>

<style>
#app {
  
}
</style>
